<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>改变链接的target属性</title>
</head>

<body>
    <a id="runoob" href="//www.runoob.com">访问菜鸟教程</a>
    <br><br>
    <input type="button" onclick="changeTarget()" value="修改target">
    <p>尝试在你单击按钮之前点击链接。</p>
    <script>
        function changeTarget() {
            document.getElementById('runoob').target = "_blank";
        }
    </script>
</body>

</html>